package com.warm.base.design.b_observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @Date: 2019/11/21 14:10
 * @Author: LChuang
 * @Description:
 */
public abstract class Subject {

    /**
     *  save register observers
     */
    protected List<Observer> observers = new ArrayList<>();

    /**
     *  register Observer
     */
    public void register(Observer observer){
        observers.add(observer);
    }

    /**
     *  remove Observer
     */
    public void remove(Observer observer){
        observers.remove(observer);
    }

    /**
     *  notify all Observer
     */
    public abstract void notifyObservers();
}
